#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    vector<int> sortArrayByParityII(vector<int>& A) {
		int odd = 1, even = 0;
		while(!(odd >= A.size() && even >= A.size())){
			while(odd < A.size() && A[odd] % 2){
				odd += 2;
			}	
			while(even < A.size() && !(A[even] % 2)){
				even += 2;
			}
			if(!(odd >= A.size() && even >= A.size())){
				int temp = A[odd];
				A[odd] = A[even];
				A[even] = temp;
			}
		}
		return A;
    }
};

int main(){
	return 0;
} 
